var StoreModule = { write: function (key, value, callback, callback_error) { try { localStorage[key] = JSON.stringify(value); if (typeof callback === "function") { callback(); } } catch (e) { if (typeof callback_error === "function") { callback_error(e); } } }, read: function (key) { return JSON.parse(localStorage[key]); }, exists: function (key) { if (localStorage.getItem(key) === null) { return false; } else { return true; } }, delete: function (key) { try { localStorage.removeItem(key); } catch (e) { } }, clear: function () { try { localStorage.clear(); } catch (e) { } }, save_last_db_logged: function () { var admin_db_id = AccountModule.get_logged_admin_db(); this.write('last_db_logged', admin_db_id); }, read_last_db_logged: function () { var last = null; if (this.exists('last_db_logged')) { last = this.read('last_db_logged'); } return last; }, save_last_user_logged: function (user) { this.write('last_user_logged', user); }, read_last_user_logged: function () { var last = ''; if (this.exists('last_user_logged')) { last = this.read('last_user_logged'); } return last; }, save_last_password_logged: function (password) { this.write('last_password_logged', password); }, read_last_password_logged: function () { var last = ''; if (this.exists('last_password_logged')) { last = this.read('last_password_logged'); } return last; }, delete_last_login: function () { if (this.exists('last_db_logged')) { this.delete('last_db_logged'); } if (this.exists('last_user_logged')) { this.delete('last_user_logged'); } if (this.exists('last_password_logged')) { this.delete('last_password_logged'); } }, storage_data_db_key: function () { var admin_db_id = AccountModule.get_logged_admin_db(); return 'db_' + admin_db_id + '_'; }, get_keys_containing_keyword: function (keyword) { var keys = []; for (var key in localStorage) { if (localStorage.hasOwnProperty(key)) { if (key.indexOf(keyword) !== -1) { keys.push(key); } } } return keys; } };